<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/7/21 0021
  Time: 下午 1:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html><head>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/easyui/bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/easyui/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/easyui/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/easyui/css/common/box.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/easyui/css/common/checkbox.css">
    <style type="text/css">
        a {
            color: black;
        }

        a:hover {
            text-decoration: none;
        }

        .bgc-w {
            background-color: #fff;
        }
        .paixu:HOVER{
            cursor: pointer;
            color:#337ab7;
        }

    </style>

</head><body><div class="row" style="padding-top: 10px;">
    <div class="col-md-2">
        <h1 style="font-size: 24px; margin: 0;" class="">通知管理</h1>
    </div>
    <div class="col-md-10 text-right">
        <a href="index"><span class="glyphicon glyphicon-home"></span> 首页</a> &gt;
        <a disabled="disabled">通知管理</a>
    </div>
</div>

<div class="row" style="padding-top: 15px;">
    <div class="col-md-12 thistable">
        <!--id="container"-->
        <div class="bgc-w box box-primary">
            <!--盒子头-->
            <div class="box-header">
                <h3 class="box-title">
                    <a href="xinzeng.jsp" class="label label-success" style="padding: 5px;"> <span class="glyphicon glyphicon-plus"></span>
                        新增
                    </a>
                    <a href="" class="label label-success" style="padding: 5px;margin-left:5px;">
                        <span class="glyphicon glyphicon-refresh"></span> 刷新
                    </a>
                </h3>
                <div class="box-tools">
                    <div class="input-group" style="width: 150px;">
                        <input type="text" class="form-control input-sm baseKey" id="put" placeholder="按标题查找" value="">
                        <div class="input-group-btn">
                            <a class="btn btn-sm btn-default baseKetsubmit"><span class="glyphicon glyphicon-search" id="dianji"></span></a>
                        </div>
                    </div>
                </div>
            </div>
            <!--盒子身体-->
            <div class="box-body no-padding">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th scope="col"><span class="paixu thistype">类型
						</span></th>
                            <th scope="col"><span class="paixu thisstatus">状态
						</span></th>
                            <th scope="col">标题</th>
                            <th scope="col"><span class="paixu thistime">发布时间
						</span></th>
                            <th scope="col">发布人</th>
                            <th scope="col">部门</th>
                            <th scope="col" >操作</th>
                        </tr>
                        </thead>
                        <tbody class="tb">

                        </tbody>
                    </table>
                </div>



            </div>
            <!--盒子尾-->
            <div class="box-footer no-padding" style="margin-top: 10px;">
                <div style="padding: 5px;">
                    <div id="page" style="background: #fff; border: 0px; margin-top: 0px; padding: 2px; height: 25px;">
                        <div style="width: 40%; float: left;">
                            <div class="pageInfo" style="margin-left: 5px;">
                                <%-- 共<span>3</span>条 | 每页<span>3</span>条
                                 | 共<span>1</span>页--%>
                            </div>
                        </div>
                        <div style="width: 60%; float: left;">
                            <div class="pageOperation">
                                <%-- <a class="btn btn-sm btn-default no-padding tablefirst" disabled="disabled" style="width: 30px; height: 20px;"> <span class="glyphicon glyphicon-backward"></span></a>
                                 <a class="btn btn-sm btn-default no-padding tableup" disabled="disabled" style="width: 30px; height: 20px;"> <span class="glyphicon glyphicon-triangle-left"></span></a>
                                 <a disabled="disabled" class="btn btn-default no-padding" style="width: 30px; height: 20px;"> 1 </a>
                                 <!--判断是否是最后一页  -->
                                 <a class="btn btn-sm btn-default no-padding tabledown" disabled="disabled" style="width: 30px; height: 20px;"> <span class="glyphicon glyphicon-triangle-right"></span></a>
                                 <a class="btn btn-sm btn-default no-padding tablelast" disabled="disabled" style="width: 30px; height: 20px;"> <span class="glyphicon glyphicon-forward"></span></a>--%>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <script>
                $(document).ready(function () {

                    /*删除通知邮件ajax请求*/
                    $(document).on('click','#shanchu',function () {
                        alert("确认删除");
                        $.ajax({
                            async: true,
                            type:"GET",
                            /*自定义属性*/
                            url:"${pageContext.request.contextPath}/insert/delect?typeid="+$("#shanchu").data("typeid"),
                            dataType:"json",
                            success:function (result) {
                                if (result.state){
                                    alert(result.msg);
                                    /*跳转当前页*/
                                    window.location.href = 'notice.jsp';
                                }else{
                                    alert(result.msg);
                                }
                            },
                            error:function (result) {
                                alert("操作失败");
                            }

                        })

                    })

                    var pageNum  = 1;
                    var pageSize = 5;
                    /*   页面一进入请求分页数据*/
                    sendajax(pageNum,pageSize)


                    function sendajax(pageNum,pageSize){
                        $.ajax({
                            async:true,
                            type:"GET",
                            url:"${pageContext.request.contextPath}/insert/findlist",
                            data:{
                                pageNum :pageNum,
                                pageSize :pageSize,

                            },
                            dataType:"json",
                            success:function (result) {
                                /*渲染数据*/
                                var cou="";
                                $.each(result.list,function (index,res) {
                                    cou +="<tr>\n" +
                                        "                            <td>"+res.informEntities[0].typrName+"</td>\n" +
                                        "                            <td><span class=\"label label-primary\">"+res.statusLists[0].statusName+"</span></td>\n" +
                                        "                            <td><span>"+res.biaoTi+"</span></td>\n" +
                                        "                            <td><span>"+res.sendTime+"</span></td>\n" +
                                        "                            <td><span>"+res.peoPle+"</span></td>\n" +
                                        "                            <td><span>"+res.buMen+"</span></td>\n" +
                                        "                            <<%--td><span class=\"labels\"><label><input type=\"checkbox\" disabled=\"\"><i>✓</i></label></span></td>\n"+
    "                            <td><span class=\"labels\"></span></td>--%>\n" +
                                        "                               <td><a href=\"/insert/byidlist?id="+res.id+"\"class=\"label xiugai\"><span class=\"glyphicon glyphicon-edit\"></span>\n" +
                                        "                                修改</a>\n" +
                                        "                                <a href=\"${pageContext.request.contextPath}/insert/chakan?id="+res.id+"\" class=\"label xiugai \"><span class=\"glyphicon glyphicon-search\"></span> 查看</a>\n" +
                                        "                                <a id=\"shanchu\" /*/!*onclick=\"{return confirm('删除该记录将不能恢复，确定删除吗？');};\"*!/ */data-typeid="+res.id+" /*href=\"insert/delect?id="+res.id+"\"*/ class=\"label shanchu\"><span class=\"glyphicon glyphicon-remove\"></span> 删除</a></td>\n" +
                                        "                        </tr>";


                                });
                                $(".tb").html(cou);


                                var pageContent = " <div class=\"box-footer no-padding\" style=\"margin-top: -20px;\">\n" +
                                    "                <div style=\"padding: 5px;\">\n" +
                                    "                    <div id=\"page\" style=\"background: #fff; border: 0px; margin-top: 0px; padding: 2px; height: 25px;\">\n" +
                                    "                        <div style=\"width: 40%; float: left;\">\n" +
                                    "                            <div class=\"pageInfo\" style=\"margin-left: 5px;\">\n" +
                                    "                                共<span>"+result.total+"</span>条 | 每页<span>"+result.pageSize+"</span>条\n" +
                                    "                                | 共<span>"+result.pages+"</span>页\n" +
                                    "                            </div>\n" +
                                    "                        </div>\n" +
                                    "                        <div style=\"width: 60%; float: left;\">\n" +
                                    "                            <div class=\"pageOperation\">";

                                // 分页数据的渲染
                                //首页+上一页
                                if (result.pageNum == 1){
                                    pageContent += "<a class=\"btn btn-sm btn-default no-padding tablefirst\" disabled=\"disabled\" title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-backward\"></span>\n" +
                                        "                                </a>\n" +
                                        "                                <a class=\"btn btn-sm btn-default no-padding tableup\" disabled=\"disabled\" title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-triangle-left\"></span>\n" +
                                        "                                </a>";
                                }else{
                                    pageContent += "<a class=\"btn btn-sm btn-default no-padding tablefirst\"  title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-backward\"></span>\n" +
                                        "                                </a>\n" +
                                        "                                <a class=\"btn btn-sm btn-default no-padding tableup\"title=\""+result.prePage+"\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-triangle-left\"></span>\n" +
                                        "                                </a>";
                                }
                                // 页码
                                for (let i = 1;i<=result.pages;i++){
                                    if (result.pageNum == i){
                                        pageContent += " <a disabled=\"disabled\" class=\"btn btn-default no-padding num\" title=\""+i+"\" style=\"width: 30px; height: 20px;\">\n" +
                                            ""+i+"\n" +
                                            "</a>";
                                    }else{
                                        pageContent += " <a class=\"btn btn-default no-padding num\" title=\""+i+"\" style=\"width: 30px; height: 20px;\">\n" +
                                            ""+i+"\n" +
                                            "</a>";
                                    }
                                }
                                //下一页和尾页
                                if (result.pageNum == result.pages){
                                    pageContent += " <a class=\"btn btn-sm btn-default no-padding tabledown\" disabled=\"disabled\" title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-triangle-right\"></span>\n" +
                                        "                                </a>\n" +
                                        "                                <a class=\"btn btn-sm btn-default no-padding tablelast\" disabled=\"disabled\" title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-forward\"></span>\n" +
                                        "                                </a>";
                                } else{
                                    pageContent += " <a class=\"btn btn-sm btn-default no-padding tabledown\"  title=\""+result.nextPage+"\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-triangle-right\"></span>\n" +
                                        "                                </a>\n" +
                                        "                                <a class=\"btn btn-sm btn-default no-padding tablelast\"  title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                                        "                                    <span class=\"glyphicon glyphicon-forward\"></span>\n" +
                                        "                                </a>";

                                }
                                pageContent += " </div>\n" +
                                    "                                </div>\n" +
                                    "                            </div>\n" +
                                    "                        </div>\n" +
                                    "                    </div>"
                                /*pageContent += "<a class=\"btn btn-sm btn-default no-padding tabledown\" style=\"width: 30px; height: 20px;\"> " +
                                                "<span class=\"glyphicon glyphicon-triangle-right\"></span><a href=\"#\" title=\""+result.nextPage+"\">下一页</a>"
                                pageContent+="<a class=\"btn btn-sm btn-default no-padding tablelast\" style=\"width: 30px; height: 20px;\"> " +
                                             "<span class=\"glyphicon glyphicon-forward\"></span><a href=\"#\" title=\""+result.pages+"\">尾页</a>"
*/


                                $(".box-footer").html(pageContent);

                            },
                            error:function () {
                                alert("失败");
                            }

                        });


                    }



                })



            </script>
<%--注释--%>
            <script>


                $(document).on("click",".pageOperation a" ,function () {
                    var pageNum = $(this).prop("title"); // 每一个a标签的title属性值就是页码
                    // 发送请求
                    var pageSize = 5;
                    send(pageNum,pageSize);
                })

                /*根据标题模糊查询*/
                $("#dianji").click(function () {
                    var pageNum  = 1;
                    var pageSize = 5;
                    send(pageNum,pageSize);

                });
                function send(pageNum,pageSize) {
                    var put = $("#put").val();
                    $.ajax({
                        async:true,
                        type:"GET",
                        url:"${pageContext.request.contextPath}/insert/list",
                        data:{
                            BiaoTi:put,
                            pageNum:pageNum,
                            pageSize:pageSize
                        },
                        dataType:"json",
                        success:function (result) {
                            /*渲染数据*/
                            var cou="";
                            $.each(result.list,function (index,res) {

                                cou +="<tr>\n" +
                                    "                            <td>"+res.informEntities[0].typrName+"</td>\n" +
                                    "                            <td><span class=\"label label-primary\">"+res.statusLists[0].statusName+"</span></td>\n" +
                                    "                            <td><span>"+res.biaoTi+"</span></td>\n" +
                                    "                            <td><span>"+res.sendTime+"</span></td>\n" +
                                    "                            <td><span>"+res.peoPle+"</span></td>\n" +
                                    "                            <td><span>"+res.buMen+"</span></td>\n" +
                                    "                            <<%--td><span class=\"labels\"><label><input type=\"checkbox\" disabled=\"\"><i>✓</i></label></span></td>\n"+
    "                            <td><span class=\"labels\"></span></td>--%>\n" +
                                    "                               <td><a href=\"${pageContext.request.contextPath}/insert/byidlist?id="+res.id+"\"class=\"label xiugai\"><span class=\"glyphicon glyphicon-edit\"></span>\n" +
                                    "                                修改</a>\n" +
                                    "                                <a href=\"${pageContext.request.contextPath}/insert/chakan?id="+res.id+"\" class=\"label xiugai \"><span class=\"glyphicon glyphicon-search\"></span> 查看</a>\n" +
                                    "                                <a id=\"shanchu\" /*/!*onclick=\"{return confirm('删除该记录将不能恢复，确定删除吗？');};\"*!/ */data-typeid="+res.id+" /*href=\"insert/delect?id="+res.id+"\"*/ class=\"label shanchu\"><span class=\"glyphicon glyphicon-remove\"></span> 删除</a></td>\n" +
                                    "                        </tr>";

                            });
                            $(".tb").html(cou);
                            var pageContent = " <div class=\"box-footer no-padding\" style=\"margin-top: -20px;\">\n" +
                                "                <div style=\"padding: 5px;\">\n" +
                                "                    <div id=\"page\" style=\"background: #fff; border: 0px; margin-top: 0px; padding: 2px; height: 25px;\">\n" +
                                "                        <div style=\"width: 40%; float: left;\">\n" +
                                "                            <div class=\"pageInfo\" style=\"margin-left: 5px;\">\n" +
                                "                                共<span>"+result.total+"</span>条 | 每页<span>"+result.pageSize+"</span>条\n" +
                                "                                | 共<span>"+result.pages+"</span>页\n" +
                                "                            </div>\n" +
                                "                        </div>\n" +
                                "                        <div style=\"width: 60%; float: left;\">\n" +
                                "                            <div class=\"pageOperation\">";

                            // 分页数据的渲染
                            //首页+上一页
                            if (result.pageNum == 1){
                                pageContent += "<a class=\"btn btn-sm btn-default no-padding tablefirst\" disabled=\"disabled\" title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-backward\"></span>\n" +
                                    "                                </a>\n" +
                                    "                                <a class=\"btn btn-sm btn-default no-padding tableup\" disabled=\"disabled\" title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-triangle-left\"></span>\n" +
                                    "                                </a>";
                            }else{
                                pageContent += "<a class=\"btn btn-sm btn-default no-padding tablefirst\"  title=\"1\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-backward\"></span>\n" +
                                    "                                </a>\n" +
                                    "                                <a class=\"btn btn-sm btn-default no-padding tableup\"title=\""+result.prePage+"\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-triangle-left\"></span>\n" +
                                    "                                </a>";
                            }
                            // 页码
                            for (let i = 1;i<=result.pages;i++){
                                if (result.pageNum == i){
                                    pageContent += " <a disabled=\"disabled\" class=\"btn btn-default no-padding num\" title=\""+i+"\" style=\"width: 30px; height: 20px;\">\n" +
                                        ""+i+"\n" +
                                        "</a>";
                                }else{
                                    pageContent += " <a class=\"btn btn-default no-padding num\" title=\""+i+"\" style=\"width: 30px; height: 20px;\">\n" +
                                        ""+i+"\n" +
                                        "</a>";
                                }
                            }
                            //下一页和尾页
                            if (result.pageNum == result.pages){
                                pageContent += " <a class=\"btn btn-sm btn-default no-padding tabledown\" disabled=\"disabled\" title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-triangle-right\"></span>\n" +
                                    "                                </a>\n" +
                                    "                                <a class=\"btn btn-sm btn-default no-padding tablelast\" disabled=\"disabled\" title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-forward\"></span>\n" +
                                    "                                </a>";
                            } else{
                                pageContent += " <a class=\"btn btn-sm btn-default no-padding tabledown\"  title=\""+result.nextPage+"\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-triangle-right\"></span>\n" +
                                    "                                </a>\n" +
                                    "                                <a class=\"btn btn-sm btn-default no-padding tablelast\"  title=\""+result.pages+"\" style=\"width: 30px; height: 20px;\">\n" +
                                    "                                    <span class=\"glyphicon glyphicon-forward\"></span>\n" +
                                    "                                </a>";

                            }
                            pageContent += " </div>\n" +
                                "                                </div>\n" +
                                "                            </div>\n" +
                                "                        </div>\n" +
                                "                    </div>"
                            /*pageContent += "<a class=\"btn btn-sm btn-default no-padding tabledown\" style=\"width: 30px; height: 20px;\"> " +
                                            "<span class=\"glyphicon glyphicon-triangle-right\"></span><a href=\"#\" title=\""+result.nextPage+"\">下一页</a>"
                            pageContent+="<a class=\"btn btn-sm btn-default no-padding tablelast\" style=\"width: 30px; height: 20px;\"> " +
                                         "<span class=\"glyphicon glyphicon-forward\"></span><a href=\"#\" title=\""+result.pages+"\">尾页</a>"
*/


                            $(".box-footer").html(pageContent);

                        },

                        error:function (result) {
                            alert("未找到标题,请重新输入");
                        }

                    })
                }

            </script>


    </div>
</body></html>
